#ifndef VLCKITS_H
#define VLCKITS_H

#include <QObject>
#include <vlc/vlc.h>

#include <vector>
using std::vector;

class VLCKits : public QObject
{
    Q_OBJECT
public:
    explicit VLCKits(QObject *parent = nullptr);
    ~VLCKits();

    bool initVLC();
    bool play(int index, void * hwnd);
    void play();
    void pause();
    void stop();
    void setPosition(int value);

    libvlc_media_player_t * mediaPlayer() const { return _pMediaPlayer;   }
    //libvlc_time_t durations() const {   return _totalSec;   }

    //当需要修改UI界面的显示时，通过信号来触发，以下三个函数调用时就触发信号
    void setTimeSliderPos(int value);
    void setTimeText(const QString & str);
    void setCurPlayTime(const qint64 & curMs);
    void setTotalTime(const qint64 & tatalMs);
    void setVolumePos(int value);

    //添加的成员函数
    bool play(const QStringList & names, void * hwnd);

    void addMediaIndex();
    int currentIndex() const {  return _currentIndex;   }
    const vector<libvlc_time_t> & durationArr() const
    {   return _durationArr;    }

    QString getCurrentPlayingFile();

    bool addlist(const QString &filename);

signals://自定义信号
    void sigTimeSliderPos(int value);
    void sigCurPlay(const qint64 & curMs);
    void sigTotal(const qint64 & tatalMs);
    void sigVolumeSliderPos(int value);
    void updateCurrentFileShow(int idx);

public slots:
    void setVolume(int value);

private:
    libvlc_instance_t *         _pInstance = nullptr;
    libvlc_media_t *            _pMedia = nullptr;
    libvlc_media_player_t *     _pMediaPlayer = nullptr;
    libvlc_event_manager_t *    _pEventManager = nullptr;
    //libvlc_time_t _totalSec = 0;//一个文件的总时间

    //添加的数据成员
    libvlc_media_list_player_t * _pMediaListPlayer = nullptr;
    libvlc_media_list_t *        _pMediaList = nullptr;
    vector<libvlc_time_t>        _durationArr;
    int _currentIndex = -1;//表示当前播放的媒体下标
    QStringList _names;

};

#endif // VLCKITS_H
